blktap: Revert parts of c/s 19349.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 1 Jun 2009 13:02:26 +0000 (14:02 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 1 Jun 2009 13:02:26 +0000 (14:02 +0100)
Caused blktapctrl pipes to be created with uninitialised variable in name.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/blktap/drivers/blktapctrl.c

index 8a5630230e20762562503c95f36ff34e15e61790..21cdfe5239e4bfda549e510fac9805d52a7d76f9 100644 (file)
@@ -659,6 +659,9 @@ static int blktapctrl_new_blkif(blkif_t *blkif)
 
        DPRINTF("Received a poll for a new vbd\n");
        if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) {
+               if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0)
+                       return -1;
+
                if (test_path(blk->params, &ptr, &type, &exist, &use_ioemu) != 0) {
                         DPRINTF("Error in blktap device string(%s).\n",
                                 blk->params);
@@ -682,6 +685,10 @@ static int blktapctrl_new_blkif(blkif_t *blkif)
                        blkif->fds[WRITE] = exist->fds[WRITE];
                }
 
+               add_disktype(blkif, type);
+               blkif->major = major;
+               blkif->minor = minor;
+
                image = (image_t *)malloc(sizeof(image_t));
                blkif->prv = (void *)image;
                blkif->ops = &tapdisk_ops;
@@ -705,18 +712,11 @@ static int blktapctrl_new_blkif(blkif_t *blkif)
                        goto fail;
                }
 
-               if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0)
-                       return -1;
-
-               blkif->major = major;
-               blkif->minor = minor;
-
-               add_disktype(blkif, type);
-
        } else return -1;
 
        return 0;
 fail:
+       ioctl(ctlfd, BLKTAP_IOCTL_FREEINTF, minor);
        return -EINVAL;
 }